package com.hz.cheetahclient.config;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * Created by yangchuan on 18/3/21.
 */
public class ClientConfigRegistrar implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {

        if (!beanDefinitionRegistry.containsBeanDefinition(CheetahClientInit.BEAN_NAME)) {
            RootBeanDefinition beanDefinition = new RootBeanDefinition(CheetahClientInit.class);
            beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
            beanDefinitionRegistry.registerBeanDefinition(CheetahClientInit.BEAN_NAME, beanDefinition);
        }
    }
}
